import axios from "axios"
import qs from "qs"

let instance = axios.create({
    baseURL: 'http://localhost:8081',
    // baseURL: 'http://192.168.181.47:8081',
    timeout: 5000,
})

instance.interceptors.request.use(config => {
    if (config.method == "post") {
        config.data = qs.stringify({ ...config.data })
    } else {
        config.params = { ...config.params }
    }
    config.headers["Content-Type"] = "application/X-www-form-urlencoded";
    return config
},
    err => {
        return Promise.reject(err)
    }
)

instance.interceptors.response.use(
    response => {
        return response
    },
    error => {
        return Promise.reject(error)
    }
)


export default instance
